//
//  FQAnswerSectionController.swift
//  SwiftProject
//
//  Created by 董駸 on 2022/9/5.
//

import UIKit

class FQAnswerSectionController: BaseListSectionController {
    var model : FQAnswerModel!
    
    override init() {
        super.init()
        inset = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
    }
    
    override func sizeForItem(at index: Int) -> CGSize {
        let height = model.model.answer.getStringHeight(font: .rSFont(14), maxWidth: SCREEN_WIDTH - 32 - 40)
        return CGSize(width: SCREEN_WIDTH - 32, height: 49 + 30 + height)
    }
    
    override func cellForItem(at index: Int) -> UICollectionViewCell {
        let cell = dequeueReusableCell(cellType: FQAnswerCollectionViewCell.self, index: index)
        cell.model = model
        return cell
    }
    
    override func didUpdate(to object: Any) {
        model = object as? FQAnswerModel
    }
}
